home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LTP_DefaultEditRoutine.c < prev    next >
C/C++ Source or Header  |  1995-09-24  |  3KB  |  162 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. ULONG __asm __saveds
  10. LTP_DefaultEditRoutine(register __a0 struct Hook *Hook,register __a2 struct SGWork *Work,register __a1 ULONG *Msg)
  11. {
  12.     if(*Msg == SGH_KEY)
  13.     {
  14.         if(Work -> IEvent -> ie_Code == 0x5F)
  15.         {
  16.             LayoutHandle *Handle = Hook -> h_Data;
  17.  
  18.             if(Handle -> HelpHook)
  19.             {
  20.                 Work -> Code    = 0x5F;
  21.                 Work -> Actions    = (Work -> Actions & ~SGA_BEEP) | SGA_END | SGA_USE;
  22.  
  23.                 LTP_AddHistory(Work);
  24.  
  25.                 return(TRUE);
  26.             }
  27.         }
  28.  
  29.         if(Work -> IEvent -> ie_Code == CURSORUP || Work -> IEvent -> ie_Code == CURSORDOWN)
  30.             LTP_HandleHistory(Work);
  31.  
  32.         if(Work -> EditOp == EO_ENTER)
  33.         {
  34.             LayoutHandle    *Handle = Hook -> h_Data;
  35.             ObjectNode    *Node;
  36.             BOOLEAN      Activate = TRUE;
  37.  
  38.             DB(kprintf("enter operation\n"));
  39.  
  40.             if(GETOBJECT(Work -> Gadget,Node))
  41.             {
  42.                 if(Node -> Type == STRING_KIND)
  43.                 {
  44.                     if(Node -> Special . String . LastGadget)
  45.                         Activate = FALSE;
  46.                 }
  47. #ifndef DO_HEXHOOK
  48.                 else
  49.                 {
  50.                     if(Node -> Type == INTEGER_KIND)
  51.                     {
  52.                         if(Node -> Special . Integer . LastGadget)
  53.                             Activate = FALSE;
  54.                     }
  55.                 }
  56. #endif
  57.             }
  58.  
  59.             if(!(Work -> IEvent -> ie_Qualifier & QUALIFIER_SHIFT))
  60.             {
  61.                 DB(kprintf("no shift\n"));
  62.  
  63.                 if(Activate && Handle -> AutoActivate)
  64.                     Work -> Actions |= SGA_NEXTACTIVE;
  65.  
  66.                 if(!(Work -> Actions & SGA_NEXTACTIVE))
  67.                     Work -> Code = '\r';
  68.             }
  69.             else
  70.                 DB(kprintf("has shift\n"));
  71.         }
  72.  
  73.         if(Work -> IEvent -> ie_Code == CURSORRIGHT && (Work -> IEvent -> ie_Qualifier & QUALIFIER_CONTROL))
  74.         {
  75.             if(Work -> BufferPos != Work -> NumChars)
  76.             {
  77.                 WORD i,Position = -1;
  78.  
  79.                 for(i = Work -> BufferPos ; i < Work -> NumChars ; i++)
  80.                 {
  81.                     if(Work -> WorkBuffer[i] == ' ')
  82.                     {
  83.                         for( ; i < Work -> NumChars ; i++)
  84.                         {
  85.                             if(Work -> WorkBuffer[i] != ' ')
  86.                             {
  87.                                 Position = i;
  88.  
  89.                                 break;
  90.                             }
  91.                         }
  92.  
  93.                         break;
  94.                     }
  95.                 }
  96.  
  97.                 if(Position != -1)
  98.                     Work -> BufferPos = Position;
  99.                 else
  100.                     Work -> BufferPos = Work -> NumChars;
  101.  
  102.                 Work -> EditOp = EO_MOVECURSOR;
  103.             }
  104.         }
  105.  
  106.         if(Work -> IEvent -> ie_Code == CURSORLEFT && (Work -> IEvent -> ie_Qualifier & QUALIFIER_CONTROL))
  107.         {
  108.             if(Work -> BufferPos)
  109.             {
  110.                 WORD i,Position = -1;
  111.  
  112.                 for(i = Work -> BufferPos ; i >= 0 ; i--)
  113.                 {
  114.                     if(Work -> WorkBuffer[i] != ' ')
  115.                     {
  116.                         Position = i;
  117.  
  118.                         break;
  119.                     }
  120.                 }
  121.  
  122.                 if(Position == -1)
  123.                     Position = 0;
  124.  
  125.                 if(Position)
  126.                 {
  127.                     i = Position;
  128.  
  129.                     Position = -1;
  130.  
  131.                     for( ; i >= 0 ; i--)
  132.                     {
  133.                         if(Work -> WorkBuffer[i] == ' ')
  134.                         {
  135.                             Position = i + 1;
  136.  
  137.                             break;
  138.                         }
  139.                     }
  140.                 }
  141.  
  142.                 if(Position != -1)
  143.                     Work -> BufferPos = Position;
  144.                 else
  145.                     Work -> BufferPos = 0;
  146.  
  147.                 Work -> EditOp = EO_MOVECURSOR;
  148.             }
  149.         }
  150.  
  151.         if(Work -> Actions & SGA_END)
  152.             LTP_AddHistory(Work);
  153.     }
  154.     else
  155.     {
  156.         if(*Msg != SGH_CLICK)
  157.             return(FALSE);
  158.     }
  159.  
  160.     return(TRUE);
  161. }
  162.